package xyz.xuminghai.javafx_learn.stage;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;

import java.io.File;

/**
 * 2023/1/9 15:24 星期一<br/>
 * <p>
 * 目录选择器
 *
 * @author xuMingHai
 */
public class DirectoryChooserApp extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        Button button = new Button("选择文件夹");
        DirectoryChooser directoryChooser = new DirectoryChooser();
        button.setOnAction(event -> {
            File file = directoryChooser.showDialog(primaryStage);
            System.out.println("file = " + file);
        });

        primaryStage.setScene(new Scene(button));
        primaryStage.setTitle("DirectoryChooserApp");
        primaryStage.show();
    }

}
